package com.mall.controller;

import com.mall.pageResult.PageResult;
import com.mall.pojo.SmsCouponHistory;
import com.mall.service.CouponHistoryService;
import com.mall.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/couponHistory")
public class CouponHistoryController {

    @Autowired
    private CouponHistoryService couponHistoryService;

    /**
     * 根据优惠券id，使用状态，订单编号分页获取领取记录
     * @param pageNum
     * @param pageSize
     * @param couponId
     * @param useStatus
     * @param orderSn
     * @return
     */
    @GetMapping("/list")
    public Result<PageResult<SmsCouponHistory>> list(@RequestParam(value = "pageNum", required = false) Integer pageNum,
                                                     @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                     @RequestParam(required = false) Integer couponId,
                                                     @RequestParam(required = false) Integer useStatus,
                                                     @RequestParam(required = false) String orderSn){
        PageResult<SmsCouponHistory> result = couponHistoryService.list(pageNum,pageSize,couponId,useStatus,orderSn);
        return Result.success(result,"操作成功");
    }
}
